package com.hangxiang.approval.controller;

import com.hangxiang.approval.common.*;
import com.hangxiang.approval.service.RoleMenuService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * (RoleMenu)表控制层
 *
 * @author makejava
 * @since 2020-11-26 14:01:42
 */
@RestController
@RequestMapping("roleMenu")
@Api(tags = "角色菜单相关功能")
public class RoleMenuController {
    /**
     * 服务对象
     */
    @Resource
    private RoleMenuService roleMenuService;

    /**
     * 通过主键查询单条数据
     *
     * @param common 主键
     * @return 单条数据
     */
    @PostMapping("selectOne")
    @ApiOperation(value = "通过主键查询单条数据")
    @ResponseBody
    public ResultBean selectOne(@RequestBody @Validated IntegerCommon common) {
        return ResultBean.success(roleMenuService.queryById(common));
    }


    /**
     * 新增数据
     *
     * @param roleMenuInsertCommon 实例对象
     * @return 实例对象
     */
    @PostMapping("insertRoleMenu")
    @ApiOperation(value = "添加数据")
    @ResponseBody
    public ResultBean insertRoleMenu(@RequestBody @Validated RoleMenuInsertCommon roleMenuInsertCommon) {
        return ResultBean.success(roleMenuService.insertRoleMenu(roleMenuInsertCommon));
    }

    /**
     * 新增数据
     *
     * @param
     * @return 实例对象
     */
    @PostMapping("insertRoleMenuList")
    @ApiOperation(value = "添加菜单数据")
    @ResponseBody
    public ResultBean insertRoleMenuList(@RequestBody @Validated RoleMenuNewCommon roleMenuNewCommon) {
        roleMenuService.insertRoleMenuList(roleMenuNewCommon);
        return ResultBean.success();
    }



    /**
     * 新增数据
     *
     * @param roleMenuUpdateCommon 实例对象
     * @return 实例对象
     */
    @PostMapping("updateRoleMenu")
    @ApiOperation(value = "修改数据")
    @ResponseBody
    public ResultBean updateRoleMenu(@RequestBody @Validated RoleMenuUpdateCommon roleMenuUpdateCommon) {
        return ResultBean.success(roleMenuService.updateRoleMenu(roleMenuUpdateCommon));
    }


}